<template>
  <div class="explain">
    <el-form
      ref="ruleForm"
      :model="ruleForm"
      label-width="200px"
      class="demo-ruleForm"
      style="margin-bootom: 30px"
    >
      <el-form-item prop="descriptions">
        <div slot="label">首页鲜花榜标签页面说明</div>
        <br />
        <el-input
          type="textarea"
          v-model.trim="ruleForm.descriptions"
          style="width: 60%"
          :maxlength="300"
          show-word-limit
          :placeholder="placeholder"
        ></el-input>
      </el-form-item>
    </el-form>
    <!-- form-footer -->
    <div class="form-footer" style="">
      <el-button type="success" @click="onSubmit">保存</el-button>
    </div>
  </div>
</template>

<script>
import {
  getDescriptions,
  addDescriptions
} from '@/api/flowerActive/flowerActiveList/addEdit'
export default {
  data() {
    return {
      // 表单参数
      ruleForm: {
        descriptions: '' //首页鲜花榜标签页面说明
      },
      placeholder:
        '参与鲜花榜活动，分享你的好作品，收集到的鲜花可兑换积分，也可兑换奖品，排行榜靠前还有额外奖品！'
    }
  },
  async created() {
    await this.getExpain()
  },
  methods: {
    // 获取鲜花活动说明
    async getExpain() {
      await getDescriptions((res) => {
        this.$set(this.ruleForm, 'descriptions', res)
      })
    },
    // 提交功能
    onSubmit() {
      let addActivesss
      this.$refs['ruleForm'].validate((valid) => {
        if (!valid) {
          this.$message.warning('请检查必填项')
        } else {
          // 说明内容参数
          let params = {
            descriptions: this.ruleForm.descriptions
          }
          addDescriptions(
            params,
            (res) => {},
            (err) => {
              this.$message.error('操作失败！！')
            }
          )
        }
      })
    }
  }
}
</script>

<style lang="less" scoped>
.explain {
  margin: 20px 20px;
  padding: 20px 20px;
  :deep(.el-form-item) {
    .el-form-item__content {
      margin-left: 35px !important;
    }
  }
}
// 保存的样式
.form-footer {
  width: 40%;
  margin: 0 auto;
  margin-top: 76px;
  margin-bottom: 20px;
}
</style>
